package org.iabako.server.dao.business;

import org.iabako.server.dao.JpaDAO;
import org.iabako.shared.entity.business.Payment;
import org.iabako.shared.entity.business.Sale;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by jose on 28/08/14.
 */

@Repository("paymentDAO")
public class PaymentDAO extends JpaDAO<Long, Payment> {

    @Override
    protected String getUniqueNumberVerificationQuery() {
        return null;
    }

    @Override
    protected String getLastNumberQuery() {
        return null;
    }

    public List<Payment> findBySale(Sale sale) {
        String query = "SELECT payment from Payment payment where payment.sale = :sale";
        return (List<Payment>) entityManager.createQuery(query).setParameter("sale", sale).getResultList();
    }
}
